﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection.Impl;

namespace StyleMVVM.DependencyInjection
{
	public static class IExportConfigurationExtensions
	{
		public static IExportConfiguration ImportConstructor(this IExportConfiguration exportConfiguration,
																				Expression<Action> importConstructorExpression)
		{
			NewExpression newExpression = importConstructorExpression.Body as NewExpression;

			if (newExpression != null)
			{
				exportConfiguration.ImportConstructor(newExpression.Constructor);
			}
			else
			{
				throw new ArgumentNullException("importConstructorExpression","You must provide a new object specifying the constructor");
			}

			return exportConfiguration;
		}
	}
}
